package main

import (
	"fmt"
	"reflect"
)

type User struct {
	Id   int
	Name string
}

func (user User) Call() {
	fmt.Println("User call")
	fmt.Println(user)
}

func main() {
	user := User{1, "tang"}

	userType := reflect.TypeOf(user)
	fmt.Println("类型:", userType.Name())

	userVal := reflect.ValueOf(user)
	fmt.Println("值:", userVal)

	fmt.Println("字段数:", userType.NumField())

	fmt.Println("第一个字段名:", userType.Field(0).Name)
	fmt.Println("第一个字段值:", userVal.Field(0).Interface())

	userMet := userType.Method(0)
	fmt.Println("方法数:", userType.NumMethod())
	fmt.Println("第一个方法名: ", userMet.Name)
	fmt.Println("第一个方法类型: ", userMet.Type)

}
